﻿using Microsoft.Extensions.DependencyInjection;
using NaturalNote.Core.Database;
using System.Data;

namespace NaturalNote.Mysql
{
    public static class NNMysqlServiceExtensions
    {
        public static IServiceCollection AddMySql(this IServiceCollection services, string connectionString)            
        {
            services.AddScoped<IDbConnection>(sp=> new MySqlConnector.MySqlConnection(connectionString));
            services.AddScoped<IDbTools>(sp => new MysqlDbTools(sp.GetRequiredService<IDbConnection>()));
            services.AddScoped<IDataQuery, MysqlDataQuery>();
            services.AddScoped<IDataStorage, MysqlDataStorage>();
            return services;
        }
    }
}